package UILag;
import java.util.Scanner;

/**
 * Write a description of class MainMenu here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MainMenuUI {
    public PersonUI person;
    public DVDsUI dvds;
    public LoanUI loan;

    /**
     * Constructor for objects of class MainMenu
     */
    public MainMenuUI() {
        person = new PersonUI();
        dvds = new DVDsUI();
        loan = new LoanUI();
    }

    public void start() {
        mainMenu();
    }

    public void mainMenu() {
        boolean exit = false;
        while(!exit) {
            // that is: while exit is false
            int choise = writeMainMenu(); 
            if(choise == 1) {
                person.start();
            }
            else if(choise == 2) {
                dvds.start();
            }
            else if(choise == 3) {
                loan.start();
            }          
            else {
                exit = true;
            }
        }//end else    
    }//end while

    public int writeMainMenu() { 
        // makes an object keyboard to read input from the screen
        Scanner keyboard = new Scanner(System.in);
        System.out.println("*** Main Menu ***");
        System.out.println(" (1) Person");
        System.out.println(" (2) DVDs");
        System.out.println(" (3) Loan");
        System.out.println(" (4) Close");
        System.out.print("\n Make your choice: ");

        int choise = keyboard.nextInt();
        if(choise > 4 || choise == 0) {
            System.out.println("WTF.. You choose " + choise +" this is not a valid number.......");
            return writeMainMenu();
        }
        else {
            return choise;
        }
    }
}
